<template>
  <div class="input-component">

    <div v-if="datas.labelText" class="input-label" :style="{ width: datas.labelWidth }">
      <span v-if="datas.required" class="required-mark">*</span>
      {{ datas.labelText }}
    </div>
    
    <el-input 
      v-model="datas.value" 
      :placeholder="datas.placeholder" 
      :type="datas.type" 
      :maxlength="datas.maxlength" 
      :disabled="datas.disabled" 
      :clearable="datas.clearable"
      :show-password="datas.showPassword"
      :prefix-icon="datas.prefixIcon"
      :suffix-icon="datas.suffixIcon"
      :rows="datas.rows"
      :style="{ width: datas.width, height: datas.height }"
      @input="handleInputChange"
    ></el-input>

  </div>
</template>

<script>
export default {
  name: 'ew-input',
  props: {
    datas: {
      type: Object,
      required: true
    }
  },
  methods: {
    // 输入变化处理函数
    handleInputChange(value) {
      // 输入变化处理函数
      console.log('输入变化处理函数',value);
    }
  }
}
</script>

<style scoped lang="less">
.input-component {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  
  .input-label {
    position: relative;
    margin-bottom: 8px;
    font-size: 14px;
    color: #606266;
    
    .required-mark {
      color: #f56c6c;
      margin-right: 4px;
    }
  }
  
  :deep(.el-input) {
    position: relative;
    width: 100%;
    height: 100%;
    
    .el-input__inner {
      height: 100%;
    }
  }
}
</style> 